<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtmll/DTD/xhtmll-transitional.dtd">
<html>
<head
<?php session_start(); 
	require_once '../menu_page/instructions.php' ?>
   <meta name="google-translate-customization" content="457c7458d78f1fda-c04c9be73e1a028e-g6dbca1555c3b1007-18"></meta>
   <LINK href="style.css" rel="stylesheet" type="text/css">
   <title>Mariachi Casa Payment Screen</title>
   <style>
      body {
         background-image:url('../game_page/chips-and-salsa.jpg');
         background-repeat:no-repeat;
      }
   </style>
</head>

<!-- ---------------------------------------------------------------- -->

<script>

function claimTicket() {

   window.open('claimTicket.html','refillWindow','titlebar=no, menubar=no, toolbar=no');
}


function tipCalculator() {

   window.open('tipCalculator.html','refillWindow','titlebar=no, menubar=no, toolbar=no');
}

function useCoupon() {

   var coupon = prompt("Input Coupon Code: ", "Coupon Code");

}


function paymentOptions() {

   window.open('paymentForm.html','refillWindow','titlebar=no, menubar=no, toolbar=no');
}


function help(){
	alert("A waiter is on the way to help you.");
	//send a note to the waiters that this tablet needs help
}

function refill(){
	//refill screen popup
	window.open('../refill_page/refillScreen.html','refillWindow','titlebar=no, menubar=no, toolbar=no');
}

</script>


<!-- ---------------------------------------------------------------- -->

<div id="google_translate_element">
</div>
<script type="text/javascript">
function googleTranslateElementInit() {
  new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'es', layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT}, 'google_translate_element');
}

</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

<body>
   <div id="backButton">
      <form action="../home_page/home.php">
      <button class="backButton" onclick="">Back</button>
      </form>
   </div>

<?php

   if(isset($_POST['coupon'])) {
	
	echo "<script type=\"text/javascript\">\nprompt(\"Input Code: \", \"Coupon Code\");\n</script>\n";
	foreach($_SESSION['left_side_item'] as $index => $value) 
		if($value == 'Sopapilla') {
			$_SESSION['customer_data'][$index] -= $master['desserts']['Sopapilla']->cost;
			unset($_SESSION['left_side_item'][$index]);
		} 
   }


   echo "<div id=\"leftSidePayment\">";
   echo "<table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"2\" style=\"border-bottom: 1pt solid black\">";
   echo "<tr style=\"font: 24pt Georgia; font-weight: bold; color: #333333\">";
   echo "<td>Tablet</td>";
   echo "<td>Item</td>";
   echo "<td>Price</td>";
   echo "</tr>";

   // This will contain the customer's payment information.
   echo "<tr>";
   echo "<td>Tablet</td>";
   echo "<td>Item</td>";
   echo "<td>Price</td>";
   echo "</tr>";

   echo "</table>";

   echo "<table width=\"100%\" border=\"1\" cellspacing=\"2\" cellpadding=\"2\" style=\"border-bottom: 1 pt solid black\"";
   echo "<tr>";
   echo "<td style=\"font: 18pt Georgia; font-weight: bold; color: #333333\">Subtotal:</td>";
   echo "<td>\n";
   foreach($_SESSION['customer_data'] as $value)
	foreach($value as $index => $some)
		if(is_string($index))
			echo $index . ",";
   foreach($_SESSION['left_side_item'] as $value)
	echo $value . ",";
   echo "</td>\n";
   echo "<td>$\n{$_SESSION['customer_data']['cost']}</td>\n";
   echo "</tr>";
   echo "<tr>";
   echo "<td style=\"font: 18pt Goergia; font-weight: bold; color: #333333\">Tax</td>";
   echo "<td>8.25%</td>";
   $tax = (.0825) * $_SESSION['customer_data']['cost'];
   $total = $tax + $_SESSION['customer_data']['cost'];
   $current_total = $total;
   printf("<td>%4.3f</td>\n",$tax);
   //echo "<td>$tax</td>\n";
   echo "</tr>";

   echo "<tr>";
   echo "<td style=\"font: 18pt Georgia; font-weight: bold; color: #333333\">Tip</td>";
   if(isset($_POST['addtip'])) {
	$tmp = "<td>\n";
	$tmp .= "<form method=\"post\">\n";
	$tmp .= "<button class=\"backButton\" name=\"small\">10%</button>\n";
	$tmp .= "<button class=\"backButton\" name=\"mid\">15%</button>\n";
	$tmp .= "<button class=\"backButton\" name=\"large\">20%</button>\n";
	$tmp .= "</form>\n";
	$tmp .= "</td>\n";
	echo $tmp;
   }
   if(isset($_POST['small'])) {
	$tip_total = ($total * .10);
	printf("<td>%4.2f</td>\n",$tip_total);
	$current_total += $tip_total;
   }
   elseif(isset($_POST['mid'])) {
	$tip_total = ($total * .15);
	printf("<td>%4.2f</td>\n",$tip_total);
	$current_total += $tip_total;
   }
   if(isset($_POST['large'])) {
	$tip_total = ($total * .20);
	printf("<td>%4.2f</td>\n",$tip_total);
	$current_total += $tip_total;
   }
   echo "</tr>\n";
   echo "</table>";

   echo "<table width=\"100%\" border=\"1\" cellspacing=\"2\" cellpadding=\"2\">";
   echo "<tr>";
   echo "<td style=\"font: 18pt Goergia; font-weight: bold; color: #333333\">Total:</td>";
   printf("<td>$%4.2f</td>\n",$current_total);
   echo "</tr>";
   echo "</table>";
   echo " </div>";


   echo "<div id=\"rightSidePayment\">";
   echo "You are currently using Tablet 1.\n";
   echo "<br/><br/>";
   echo "<button class=\"menuButton\" onClick=\"claimTicket()\">Claim a Ticket</button>";
   echo "<br/><br/>";
   echo "<button class=\"menuButton\" onClick=\"paymentOptions()\">Pay Now</button>";
   echo "<br/><br/>";

   echo "<form method=\"post\">\n";
   echo "<button class=\"menuButton\" name=\"coupon\">Coupons</button>";
   echo "</form>\n";
   echo "<br/><br/>";
   //echo "<button class=\"menuButton\" onClick=\"tipCalculator()\">Add Tip</button>";
   echo "<form method=\"post\">\n";
   echo "<button class=\"menuButton\" name=\"addtip\" >Add Tip</button>";
   echo "</form>\n";
   echo "</div>";

   echo "<div id=\"pageBottom\">";
   echo "<button class=\"footerButton\" onclick=\"\help()">Help</button>";
   echo "<button class=\"footerButton\" onclick=\"\refill()">Refill</button>";
   echo "</div>";
?>
</body>
</html>
